package com.yaoxun.console.config;

import javax.validation.Validator;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.yaoxun.console.interceptor.SecurityInterceptor;
import com.yaoxun.console.util.ValidatorUtils;

@Configuration
public class GlobalConfig implements WebMvcConfigurer {

	
	@Override
    public void addInterceptors(InterceptorRegistry registry) {
		
        registry.addInterceptor(securityInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/page/**", "/login",  "/",
                		"/css/**","/img/**", "/js/**", "/fonts/**");
        
    }
	
	
	@Bean
	public SecurityInterceptor securityInterceptor() {
		return new SecurityInterceptor();
	}
	
	@Bean
    public Validator validator() {
        return ValidatorUtils.getValidator();
    }
	
}
